import 'package:flutter/material.dart';
import 'package:mall/constant/app_colors.dart';
import 'package:mall/gen/r.dart';
import 'package:mall/utils/image_component/image_component.dart';

class AppFormItemWidget extends StatelessWidget {
  const AppFormItemWidget({
    super.key,
    required this.leftText,
    this.rightText,
    this.callback,
    this.rightWidget,
  }) : assert(rightText == null || rightWidget == null);

  final String leftText;
  // rightText 和 rightWidget 二选一
  final String? rightText;
  final Widget? rightWidget;
  final VoidCallback? callback;

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: callback,
      child: Container(
        height: 50,
        child: Row(
          children: [
            Text(
              leftText,
              style: TextStyle(
                color: AppColors.C_222222,
                fontSize: 15,
                fontWeight: FontWeight.bold,
              ),
            ),
            Spacer(),
            if (rightText != null)
              Text(
                rightText!,
                style: TextStyle(
                  color: AppColors.C_222222,
                  fontSize: 15,
                ),
              ),
            if (rightWidget != null) rightWidget!,
            SizedBox(width: 15),
            ImageComponent(R.image.goTo.path, width: 7, height: 11),
            SizedBox(width: 15),
          ],
        ),
      ),
    );
  }
}
